package com.example.wrongquestioncollection;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.wrongquestioncollection.databinding.FragmentWrongQuestionListBinding;

import java.util.Objects;

public class WrongQuestionListFragment extends Fragment implements WrongQuestionNavigator {

    private static final int WRONG_QUESTION_VIEW_MODEL = 1;

    public static WrongQuestionListFragment newInstance() {

        Bundle args = new Bundle();

        WrongQuestionListFragment fragment = new WrongQuestionListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_wrong_question_list, container, false);
        FragmentWrongQuestionListBinding binding = DataBindingUtil.bind(view);
        WrongQuestionViewModel wrongQuestionViewModel = new WrongQuestionViewModel();
        wrongQuestionViewModel.setWrongQuestionNavigator(this);
        Objects.requireNonNull(binding).setVariable(WRONG_QUESTION_VIEW_MODEL, wrongQuestionViewModel);

        return binding.getRoot();
    }

    @Override
    public void addNewEditWrongQuestion() {
        Toast.makeText(getActivity(), "Add New Wrong Question", Toast.LENGTH_SHORT).show();
    }
}
